package com.cn.bulu.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.bulu.dao.GoodsDao;
import com.cn.bulu.pojo.Goods;
import com.cn.bulu.service.PriceService;
import com.cn.bulu.utils.BuluResult;
import com.cn.bulu.utils.Monery.weixin.WeiXinPayUtil;
import com.cn.bulu.utils.Monery.weixin.util.ConstantUtil;
import com.cn.bulu.utils.Monery.zhifubao.OrderConfig;
import com.cn.bulu.utils.Monery.zhifubao.PayUtil;

@Controller
@RequestMapping("price")
public class PriceController {

	@Resource
	private PriceService priceService;
	
    @Autowired
    GoodsDao goodsDao;
    
    
	/**
	 * 成品帘价格计算
	 * @param finishList
	 * @return
	 */
	@RequestMapping("getPriceOfFinish")
	@ResponseBody					//finishList={sampleId:,finish:[{wide:,high:},{}]}
	public BuluResult getPriceOfFinish(String finishList){
		System.out.println(finishList+"-----------------------");
		BuluResult buluResult=priceService.getPriceOfFinish(finishList);
		return buluResult;
	}
	
	
	
	//布艺帘价格计算
	@RequestMapping("curtainPrice")
	@ResponseBody	
	public BuluResult curtainPrice(Goods goods){
		System.out.println("***************start**************************");
//		Map<String,Object>map=new HashMap<>();
//		map.put("goodsid", 470);
//		map.put("customerId", 1053);
//		goods=goodsDao.getPendingGoods(map);
		BuluResult buluResult = priceService.curtainPrice(goods);
		System.out.println("***************end**************************");
		return buluResult;
	}
	


    /**
     * 微信支付钱的单位是分,支付宝是元
     * 微信支付的订单号最好加上随机字符串,在处理成功时去掉
     * @return
     */

    @ResponseBody
    @RequestMapping(value = "/app/zhifubao", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public String zhifubao() {
        String sign = null;
        sign = PayUtil.ZhiFuBaoPay("下单", "历史订单支付:1212212121", "0.01", "1212212121", OrderConfig.notify_url);
        return sign;
    }

    @ResponseBody
    @RequestMapping(value = "/app/weixin", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public String weixin() {
        String sign = null;
        try {
            sign = WeiXinPayUtil.weiXinPay("192.168.0.1", "历史订单支付:" + "1212212121_12112", 1.0, "1212212121_12112", ConstantUtil.notify_url);
        } catch (Exception e) {
        }
        return sign;
    }
}
